package menu

import (
	"context"

	"go-zero-mall/app/admin/cmd/api/internal/svc"
	"go-zero-mall/app/admin/cmd/api/internal/types"
	"go-zero-mall/app/admin/cmd/rpc/pd"

	"github.com/jinzhu/copier"
	"github.com/zeromicro/go-zero/core/logx"
)

type MenuDetailLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewMenuDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MenuDetailLogic {
	return &MenuDetailLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *MenuDetailLogic) MenuDetail(req *types.MenuDetailReq) (resp *types.MenuDetailResp, err error) {
	var in pd.UmsMenuDetailReq
	copier.Copy(&in, req)
	d, err := l.svcCtx.AdminRpc.MenuDetail(l.ctx, &in)
	if err != nil {
		return nil, err
	}
	resp = &types.MenuDetailResp{}
	copier.Copy(resp, d)
	return resp, err
}
